open-with: move the "Show more applications" button in the dialog
authorCosimo Cecchi <cosimoc@gnome.org>
Mon, 22 Nov 2010 22:05:59 +0000 (23:05 +0100)
committerCosimo Cecchi <cosimoc@gnome.org>
Tue, 23 Nov 2010 15:53:22 +0000 (16:53 +0100)
It doesn't really belong in the widget now that we have the new states.

gtk/gtkopenwithdialog.c
gtk/gtkopenwithwidget.c

index 04b582726b54132fc0c449c5f638ea74315e1171..fd0aca9e0d182dd3bdce976e2219d55042fc9c49 100644 (file)
@@ -51,6 +51,7 @@ struct _GtkOpenWithDialogPrivate {
   GtkWidget *open_label;
 
   GtkWidget *open_with_widget;
+  GtkWidget *show_more_button;
 };
 
 enum {
@@ -266,13 +267,27 @@ set_dialog_properties (GtkOpenWithDialog *self)
   g_free (description);
 }
 
+static void
+show_more_button_clicked_cb (GtkButton *button,
+                            gpointer user_data)
+{
+  GtkOpenWithDialog *self = user_data;
+
+  g_object_set (self->priv->open_with_widget,
+               "show-fallback", TRUE,
+               "show-other", TRUE,
+               NULL);
+
+  gtk_widget_hide (self->priv->show_more_button);
+}
+
 static void
 build_dialog_ui (GtkOpenWithDialog *self)
 {
   GtkWidget *vbox;
   GtkWidget *vbox2;
   GtkWidget *label;
-  GtkWidget *action_area;
+  GtkWidget *action_area, *button, *w;
 
   gtk_container_set_border_width (GTK_CONTAINER (self), 5);
 
@@ -301,6 +316,17 @@ build_dialog_ui (GtkOpenWithDialog *self)
   gtk_box_pack_start (GTK_BOX (vbox2), self->priv->open_with_widget, TRUE, TRUE, 0);
   gtk_widget_show (self->priv->open_with_widget);
 
+  button = gtk_button_new_with_label (_("Show other applications"));
+  self->priv->show_more_button = button;
+  w = gtk_image_new_from_stock (GTK_STOCK_ADD,
+                               GTK_ICON_SIZE_BUTTON);
+  gtk_button_set_image (GTK_BUTTON (button), w);
+  gtk_box_pack_start (GTK_BOX (self->priv->open_with_widget), button, FALSE, FALSE, 6);
+  gtk_widget_show_all (button);
+
+  g_signal_connect (button, "clicked",
+                   G_CALLBACK (show_more_button_clicked_cb), self);
+
   gtk_dialog_add_button (GTK_DIALOG (self),
                         GTK_STOCK_CANCEL,
                         GTK_RESPONSE_CANCEL);
index 8edeb6d8a4820f49669835d1d3e3011110ca56f4..c25c2f7c730cd231b23be36b59c28300c8156d61 100644 (file)
@@ -49,12 +49,9 @@ struct _GtkOpenWithWidgetPrivate {
   gboolean radio_mode;
 
   GtkWidget *program_list;
-  GtkWidget *show_more;
   GtkListStore *program_list_store;
 
   GtkCellRenderer *padding_renderer;
-
-  gboolean show_more_clicked;
 };
 
 enum {
@@ -859,32 +856,6 @@ gtk_open_with_widget_get_property (GObject *object,
     }
 }
 
-static void
-show_more_button_clicked_cb (GtkButton *button,
-                            gpointer user_data)
-{
-  GtkOpenWithWidget *self = user_data;
-
-  self->priv->show_more_clicked = TRUE;
-  gtk_widget_hide (GTK_WIDGET (button));
-
-  _gtk_open_with_widget_refilter (self);
-}
-
-static void
-gtk_open_with_widget_ensure_show_more_button (GtkOpenWithWidget *self)
-{
-  if (self->priv->show_mode == GTK_OPEN_WITH_WIDGET_SHOW_MODE_HEADINGS)
-    {
-      if (!self->priv->show_more_clicked)
-       gtk_widget_show (self->priv->show_more);
-    }
-  else
-    {
-      gtk_widget_hide (self->priv->show_more);
-    }
-}
-
 static void
 gtk_open_with_widget_constructed (GObject *object)
 {
@@ -895,7 +866,6 @@ gtk_open_with_widget_constructed (GObject *object)
   if (G_OBJECT_CLASS (gtk_open_with_widget_parent_class)->constructed != NULL)
     G_OBJECT_CLASS (gtk_open_with_widget_parent_class)->constructed (object);
 
-  gtk_open_with_widget_ensure_show_more_button (self);
   gtk_open_with_widget_add_items (self);
 }
 
@@ -999,7 +969,7 @@ gtk_open_with_widget_class_init (GtkOpenWithWidgetClass *klass)
 static void
 gtk_open_with_widget_init (GtkOpenWithWidget *self)
 {
-  GtkWidget *scrolled_window, *button, *w;
+  GtkWidget *scrolled_window;
   GtkTreeSelection *selection;
 
   self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GTK_TYPE_OPEN_WITH_WIDGET,
@@ -1035,18 +1005,6 @@ gtk_open_with_widget_init (GtkOpenWithWidget *self)
   g_signal_connect (self->priv->program_list, "button-press-event",
                    G_CALLBACK (program_list_button_press_event_cb),
                    self);
-
-  button = gtk_button_new_with_label (_("Show other applications"));
-  w = gtk_image_new_from_stock (GTK_STOCK_ADD,
-                               GTK_ICON_SIZE_BUTTON);
-
-  gtk_button_set_image (GTK_BUTTON (button), w);
-  gtk_box_pack_start (GTK_BOX (self), button, FALSE, FALSE, 6);
-
-  g_signal_connect (button, "clicked",
-                   G_CALLBACK (show_more_button_clicked_cb), self);
-
-  self->priv->show_more = button;
 }
 
 static GAppInfo *